(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/Script/Tool/xor.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, 'ae7663E3X1MD5KX0gC9Uh1J', 'xor', __filename);
// Script/Tool/xor.js

'use strict';

var base64 = require('./base64.js');

var xorData = {

  encryptionData: function encryptionData(str, sendDic) {

    return receiveDataDecode(str, sendDic);
  }

};

var base64_encode = function base64_encode(str) {
  return base64.Base64.encode(str);
};

var alice = function alice(str, key) {
  //xor加密

  var output = '';
  var newKey = key.split("").reverse().join(""); //逆序key
  var keyLen = newKey.length - 1; //忽略key最后一个字符
  for (var i = 0; i < str.length; i++) {
    var j = i % keyLen;
    output += String.fromCharCode(str.charCodeAt(i) ^ newKey.charCodeAt(j));
  }

  return output;
};
var toAlice = function toAlice(str, key) {

  return base64_encode(alice(str, key));
};

var receiveDataDecode = function receiveDataDecode(datastring, sendDic) {

  var postdata;

  console.log("解密的字典2", sendDic);

  var key;

  key = toAlice(sendDic["appid"], String(sendDic["appver"]));

  postdata = base64_encode(JSON.stringify(datastring));

  var sendData = toAlice(postdata, key);

  return sendData;
};

module.exports = xorData;

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=xor.js.map
        